<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@include file="/init.jsp"%>
<jsp:useBean id="DataManager" class="dto.DataManager" scope="application"></jsp:useBean>
<jsp:useBean id="DtoUser" class="dto.DtoUser" scope="application"></jsp:useBean>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/scrip.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List All Users</title>
</head>
<body>
	<div class="master-wrapper-content">
		<jsp:include page="heading.jsp"></jsp:include>
		<jsp:include page="CategoryAdmin.jsp"></jsp:include>
		<div class="container-right">
				<%
					List<User> users = DataManager.getAllUser();
					if (users.isEmpty()) {
				%>
				<h2>Không có dữ liệu</h2>
				<%
					} else {
				%>
				<div class="ml-banner">
					<div class="ml-title">Quản lý User</div>
				</div>
				<table class="table-view">
					<tr class="title">
						<td width="200">Tên</td>
						<td width="200">Quyền</td>
						<td width="50"></td>
					</tr>
					<%
						for (int i = 0; i < users.size(); i++) {
								if (users.get(i).getRoleId() == 1) {
					%>
					<tr class="odd">
						<td width="200"><a href=/ECommerce/viewDetailUser.jsp?userId=<%=users.get(i).getUserId()%>><%=users.get(i).getUsername()%></a></td>
						<td width="200"><p>Admin</p></td>
						<td width="50"><a href=/ECommerce/DeleteUser?userId=<%=users.get(i).getUserId()%>>Xóa</a></td>
					</tr>
					<%
						} else {
					%>
					<tr class="even">
						<td width="200"><a href=/ECommerce/viewDetailUser.jsp?userId=<%=users.get(i).getUserId()%>><%=users.get(i).getUsername()%></a></td>
						<td width="200"><p>User</p></td>
						<td width="50"><a href=/ECommerce/DeleteUser?userId=<%=users.get(i).getUserId()%>>Xóa</a></td>
					</tr>
					<%
						}
				}
			}
				%>
			</table>
		</div>
		<div class="clear"></div>
		<jsp:include page="footer.jsp"></jsp:include>
	</div>
</body>
</html>